package com.yesun.task.pipeline.controller;

import com.yesun.task.pipeline.TaskPipelineApplication;
import com.yesun.task.pipeline.common.Constant;
import com.yesun.task.pipeline.common.JobUtil;
import com.yesun.task.pipeline.domain.dto.JobDto;
import com.yesun.task.pipeline.domain.vo.JobVo;
import com.yesun.task.pipeline.domain.vo.TaskVo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author yesun
 * @Descritpion
 * @Date 2023/8/16 21:16
 * @Version 1.0
 **/
@RestController
@RequestMapping("/rpt")
public class RptController {


    //概况
    @GetMapping("/summary")
    @CrossOrigin
    public List<JobVo> summary() {
        //返回总任务列表，标记：已完成、正在执行、未执行
        List<JobVo> list = new ArrayList<>();
        List<JobDto> listJobs = JobUtil.LIST_JOBS;
        for(JobDto jobDto : listJobs) {
            JobVo jobVo = new JobVo();
            jobVo.setJobName(jobDto.getJobName());
            jobVo.setType(jobDto.getType());
            jobVo.setTag(jobDto.getTag());
            jobVo.setMap(jobDto.getMap());
            //设置job最近执行状态 TODO
            list.add(jobVo);
        }
        return list;
    }


}
